package com.vhans.bapi.controller;

import com.vhans.core.annotation.VisitLogger;
import com.vhans.core.web.model.Result;
import com.vhans.db.model.dto.ConditionDTO;
import com.vhans.db.model.vo.quiz.QuizConditionList;
import com.vhans.db.model.vo.record.RecordConditionList;
import com.vhans.db.model.vo.tag.TagQuizVO;
import com.vhans.db.model.vo.tag.TagRecordVO;
import com.vhans.db.model.vo.tag.TagVO;
import com.vhans.db.service.IBTagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 标签控制器
 *
 * @author vhans
 **/
@Api(tags = "标签模块")
@RestController
public class TagController {

    @Autowired
    private IBTagService tagService;

    /**
     * 查看记录标签列表
     *
     * @return {@link Result<TagVO>} 记录标签列表
     */
    @VisitLogger(value = "记录标签")
    @ApiOperation(value = "查看记录标签列表")
    @GetMapping("/tag/record/list")
    public Result<List<TagRecordVO>> listTagRecordVO() {
        return Result.success(tagService.listTagRVO());
    }

    /**
     * 查看题目标签列表
     *
     * @return {@link Result<TagVO>} 题目标签列表
     */
    @VisitLogger(value = "题目标签")
    @ApiOperation(value = "查看题目标签列表")
    @GetMapping("/tag/quiz/list")
    public Result<List<TagQuizVO>> listTagQuizVO() {
        return Result.success(tagService.listTagQVO());
    }

    /**
     * 查看指定标签下的记录
     *
     * @param condition 查询条件
     * @return 记录列表
     */
    @VisitLogger(value = "标签记录")
    @ApiOperation(value = "查看标签下的记录")
    @GetMapping("/tag/record")
    public Result<RecordConditionList> listRecordTag(ConditionDTO condition) {
        return Result.success(tagService.listRecordTag(condition));
    }

    /**
     * 查看指定标签下的题目
     *
     * @param condition 查询条件
     * @return 题目列表
     */
    @VisitLogger(value = "标签题目")
    @ApiOperation(value = "查看标签下的题目")
    @GetMapping("/tag/quiz")
    public Result<QuizConditionList> listQuizTag(ConditionDTO condition) {
        return Result.success(tagService.listQuizTag(condition));
    }
}